Patch from Bill Haneman and Padraig O'Briain to add cursor_aspect_ratio
authorOwen Taylor <otaylor@redhat.com>
Thu, 14 Feb 2002 21:49:02 +0000 (21:49 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Thu, 14 Feb 2002 21:49:02 +0000 (21:49 +0000)
Thu Feb 14 16:46:48 2002  Owen Taylor  <otaylor@redhat.com>

* gtk/gtkentry.c gtk/gtktextdisplay.c gtk/gtklabel.c
gtk/gtkstyle.[ch] gtk/gtkwidget.c: Patch from Bill
Haneman and Padraig O'Briain to add cursor_aspect_ratio
style property to GtkWidget to allow theming the aspect
ratio of the cursor.

* gtk/gtkentry.c gtk/gtktextview.c gtk/gtklabel.c
gtk/gtkwidget.c tests/testgtkrc: Move cursor-color style property
to GtkWidget.

15 files changed:
ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkentry.c
gtk/gtklabel.c
gtk/gtkstyle.c
gtk/gtkstyle.h
gtk/gtktextdisplay.c
gtk/gtktextview.c
gtk/gtkwidget.c
tests/testgtkrc

index b496f4b59daa3c8742b546454702d51333c8d3ef..c99f3d094975ce9cf528cd8a6417c52128926791 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+Thu Feb 14 16:46:48 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkentry.c gtk/gtktextdisplay.c gtk/gtklabel.c
+       gtk/gtkstyle.[ch] gtk/gtkwidget.c: Patch from Bill
+       Haneman and Padraig O'Briain to add cursor_aspect_ratio
+       style property to GtkWidget to allow theming the aspect
+       ratio of the cursor.
+
+       * gtk/gtkentry.c gtk/gtktextview.c gtk/gtklabel.c
+       gtk/gtkwidget.c tests/testgtkrc: Move cursor-color style property
+       to GtkWidget.
+
 Thu Feb 14 11:13:22 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkimmulticontext.c (gtk_im_multicontext_get_surrounding): 
index b496f4b59daa3c8742b546454702d51333c8d3ef..c99f3d094975ce9cf528cd8a6417c52128926791 100644 (file)
@@ -1,3 +1,15 @@
+Thu Feb 14 16:46:48 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkentry.c gtk/gtktextdisplay.c gtk/gtklabel.c
+       gtk/gtkstyle.[ch] gtk/gtkwidget.c: Patch from Bill
+       Haneman and Padraig O'Briain to add cursor_aspect_ratio
+       style property to GtkWidget to allow theming the aspect
+       ratio of the cursor.
+
+       * gtk/gtkentry.c gtk/gtktextview.c gtk/gtklabel.c
+       gtk/gtkwidget.c tests/testgtkrc: Move cursor-color style property
+       to GtkWidget.
+
 Thu Feb 14 11:13:22 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkimmulticontext.c (gtk_im_multicontext_get_surrounding): 
index b496f4b59daa3c8742b546454702d51333c8d3ef..c99f3d094975ce9cf528cd8a6417c52128926791 100644 (file)
@@ -1,3 +1,15 @@
+Thu Feb 14 16:46:48 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkentry.c gtk/gtktextdisplay.c gtk/gtklabel.c
+       gtk/gtkstyle.[ch] gtk/gtkwidget.c: Patch from Bill
+       Haneman and Padraig O'Briain to add cursor_aspect_ratio
+       style property to GtkWidget to allow theming the aspect
+       ratio of the cursor.
+
+       * gtk/gtkentry.c gtk/gtktextview.c gtk/gtklabel.c
+       gtk/gtkwidget.c tests/testgtkrc: Move cursor-color style property
+       to GtkWidget.
+
 Thu Feb 14 11:13:22 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkimmulticontext.c (gtk_im_multicontext_get_surrounding): 
index b496f4b59daa3c8742b546454702d51333c8d3ef..c99f3d094975ce9cf528cd8a6417c52128926791 100644 (file)
@@ -1,3 +1,15 @@
+Thu Feb 14 16:46:48 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkentry.c gtk/gtktextdisplay.c gtk/gtklabel.c
+       gtk/gtkstyle.[ch] gtk/gtkwidget.c: Patch from Bill
+       Haneman and Padraig O'Briain to add cursor_aspect_ratio
+       style property to GtkWidget to allow theming the aspect
+       ratio of the cursor.
+
+       * gtk/gtkentry.c gtk/gtktextview.c gtk/gtklabel.c
+       gtk/gtkwidget.c tests/testgtkrc: Move cursor-color style property
+       to GtkWidget.
+
 Thu Feb 14 11:13:22 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkimmulticontext.c (gtk_im_multicontext_get_surrounding): 
index b496f4b59daa3c8742b546454702d51333c8d3ef..c99f3d094975ce9cf528cd8a6417c52128926791 100644 (file)
@@ -1,3 +1,15 @@
+Thu Feb 14 16:46:48 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkentry.c gtk/gtktextdisplay.c gtk/gtklabel.c
+       gtk/gtkstyle.[ch] gtk/gtkwidget.c: Patch from Bill
+       Haneman and Padraig O'Briain to add cursor_aspect_ratio
+       style property to GtkWidget to allow theming the aspect
+       ratio of the cursor.
+
+       * gtk/gtkentry.c gtk/gtktextview.c gtk/gtklabel.c
+       gtk/gtkwidget.c tests/testgtkrc: Move cursor-color style property
+       to GtkWidget.
+
 Thu Feb 14 11:13:22 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkimmulticontext.c (gtk_im_multicontext_get_surrounding): 
index b496f4b59daa3c8742b546454702d51333c8d3ef..c99f3d094975ce9cf528cd8a6417c52128926791 100644 (file)
@@ -1,3 +1,15 @@
+Thu Feb 14 16:46:48 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkentry.c gtk/gtktextdisplay.c gtk/gtklabel.c
+       gtk/gtkstyle.[ch] gtk/gtkwidget.c: Patch from Bill
+       Haneman and Padraig O'Briain to add cursor_aspect_ratio
+       style property to GtkWidget to allow theming the aspect
+       ratio of the cursor.
+
+       * gtk/gtkentry.c gtk/gtktextview.c gtk/gtklabel.c
+       gtk/gtkwidget.c tests/testgtkrc: Move cursor-color style property
+       to GtkWidget.
+
 Thu Feb 14 11:13:22 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkimmulticontext.c (gtk_im_multicontext_get_surrounding): 
index b496f4b59daa3c8742b546454702d51333c8d3ef..c99f3d094975ce9cf528cd8a6417c52128926791 100644 (file)
@@ -1,3 +1,15 @@
+Thu Feb 14 16:46:48 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkentry.c gtk/gtktextdisplay.c gtk/gtklabel.c
+       gtk/gtkstyle.[ch] gtk/gtkwidget.c: Patch from Bill
+       Haneman and Padraig O'Briain to add cursor_aspect_ratio
+       style property to GtkWidget to allow theming the aspect
+       ratio of the cursor.
+
+       * gtk/gtkentry.c gtk/gtktextview.c gtk/gtklabel.c
+       gtk/gtkwidget.c tests/testgtkrc: Move cursor-color style property
+       to GtkWidget.
+
 Thu Feb 14 11:13:22 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkimmulticontext.c (gtk_im_multicontext_get_surrounding): 
index c8363717763ce05a54ff47708c4a2dcb2a6b52d8..7c5bf59992a1f187e4189846fd1f28c831983d8a 100644 (file)
@@ -524,13 +524,6 @@ gtk_entry_class_init (GtkEntryClass *class)
                                                        "",
                                                        G_PARAM_READABLE | G_PARAM_WRITABLE));
   
-  gtk_widget_class_install_style_property (widget_class,
-                                          g_param_spec_boxed ("cursor_color",
-                                                              _("Cursor color"),
-                                                              _("Color with which to draw insertion cursor"),
-                                                              GDK_TYPE_COLOR,
-                                                              G_PARAM_READABLE));
-
   signals[POPULATE_POPUP] =
     gtk_signal_new ("populate_popup",
                    GTK_RUN_LAST,
@@ -937,7 +930,7 @@ gtk_entry_realize_cursor_gc (GtkEntry *entry)
   if (entry->cursor_gc)
     gdk_gc_unref (entry->cursor_gc);
 
-  gtk_widget_style_get (GTK_WIDGET (entry), "cursor_color", &cursor_color, NULL);
+  gtk_widget_style_get (GTK_WIDGET (entry), "cursor-color", &cursor_color, NULL);
       entry->cursor_gc = gdk_gc_new (entry->text_area);
   if (cursor_color)
     gdk_gc_set_rgb_fg_color (entry->cursor_gc, cursor_color);
@@ -2739,13 +2732,13 @@ gtk_entry_draw_cursor (GtkEntry  *entry,
       cursor_location.width = 0;
       cursor_location.height = text_area_height - 2 * INNER_BORDER ;
       
-      _gtk_draw_insertion_cursor (entry->text_area, gc1,
+      _gtk_draw_insertion_cursor (widget, entry->text_area, gc1,
                                  &cursor_location, dir1);
       
       if (gc2)
        {
          cursor_location.x = xoffset + x2;
-         _gtk_draw_insertion_cursor (entry->text_area, gc2,
+         _gtk_draw_insertion_cursor (widget, entry->text_area, gc2,
                                      &cursor_location, dir2);
        }
     }
index e038ba4119dfabd2e2fd14bd916de41563ac3d0e..b587f953cd2e571ba7055cd11173325bcf3daac7 100644 (file)
@@ -373,13 +373,6 @@ gtk_label_class_init (GtkLabelClass *class)
                                                      0,
                                                      G_PARAM_READABLE));
   
-  gtk_widget_class_install_style_property (widget_class,
-                                          g_param_spec_boxed ("cursor_color",
-                                                              _("Cursor color"),
-                                                              _("Color with which to draw insertion cursor"),
-                                                              GDK_TYPE_COLOR,
-                                                              G_PARAM_READABLE));
-  
   /*
    * Key bindings
    */
@@ -1685,7 +1678,7 @@ gtk_label_draw_cursor (GtkLabel  *label, gint xoffset, gint yoffset)
       cursor_location.width = 0;
       cursor_location.height = PANGO_PIXELS (cursor1->height);
       
-      _gtk_draw_insertion_cursor (widget->window, gc1,
+      _gtk_draw_insertion_cursor (widget, widget->window, gc1,
                                  &cursor_location, dir1);
       
       if (gc2)
@@ -1695,7 +1688,7 @@ gtk_label_draw_cursor (GtkLabel  *label, gint xoffset, gint yoffset)
          cursor_location.width = 0;
          cursor_location.height = PANGO_PIXELS (cursor2->height);
          
-         _gtk_draw_insertion_cursor (widget->window, gc2,
+         _gtk_draw_insertion_cursor (widget, widget->window, gc2,
                                      &cursor_location, dir2);
        }
     }
@@ -1938,7 +1931,7 @@ gtk_label_realize_cursor_gc (GtkLabel *label)
   if (label->select_info->cursor_gc)
     gdk_gc_unref (label->select_info->cursor_gc);
 
-  gtk_widget_style_get (GTK_WIDGET (label), "cursor_color", &cursor_color, NULL);
+  gtk_widget_style_get (GTK_WIDGET (label), "cursor-color", &cursor_color, NULL);
   label->select_info->cursor_gc = gdk_gc_new (GTK_WIDGET (label)->window);
   if (cursor_color)
     gdk_gc_set_rgb_fg_color (label->select_info->cursor_gc, cursor_color);
index fa21026ac6a5998ee993a0edf0d5ad8b15ff2813..fa81482e65cd02d39676e2ad9c6b9f5804f68f0e 100644 (file)
@@ -5474,6 +5474,7 @@ gtk_style_set_font (GtkStyle *style,
 
 /**
  * _gtk_draw_insertion_cursor:
+ * @widget: a #GtkWidget
  * @drawable: a #GdkDrawable
  * @gc: a #GdkGC
  * @location: location where to draw the cursor (@location->width is ignored)
@@ -5485,16 +5486,23 @@ gtk_style_set_font (GtkStyle *style,
  * but merely a convenience function for drawing the standard cursor shape.
  **/
 void
-_gtk_draw_insertion_cursor (GdkDrawable      *drawable,
+_gtk_draw_insertion_cursor (GtkWidget        *widget,
+                           GdkDrawable      *drawable,
                            GdkGC            *gc,
                            GdkRectangle     *location,
                            GtkTextDirection  dir)
 {
-  gint stem_width = location->height / 30 + 1;
-  gint arrow_width = stem_width + 1;
+  gint stem_width;
+  gint arrow_width;
   gint x, y;
   gint i;
+  gfloat cursor_aspect_ratio;
 
+  gtk_widget_style_get (widget, "cursor-aspect-ratio", &cursor_aspect_ratio, NULL);
+  
+  stem_width = location->height * cursor_aspect_ratio + 1;
+  arrow_width = stem_width + 1;
   for (i = 0; i < stem_width; i++)
     gdk_draw_line (drawable, gc,
                   location->x + i - stem_width / 2, location->y,
index 5ac6eb1261b015941e702879c22924a711d39fd6..9e15db578582aa504ac60c274e19ab5065670fae 100644 (file)
@@ -866,7 +866,8 @@ void gtk_paint_string     (GtkStyle        *style,
                           const gchar     *string);
 #endif /* GTK_DISABLE_DEPRECATED */
 
-void _gtk_draw_insertion_cursor (GdkDrawable      *drawable,
+void _gtk_draw_insertion_cursor (GtkWidget        *widget,
+                                GdkDrawable      *drawable,
                                 GdkGC            *gc,
                                 GdkRectangle     *location,
                                 GtkTextDirection  dir);
index fd5a9d137e27921337a8a9eb44ee492ba5a7dcf4..b3acdab830d9b62946e51651dcafebe50661b85d 100644 (file)
@@ -859,7 +859,7 @@ gtk_text_layout_draw (GtkTextLayout *layout,
              cursor_location.height = cursor->height;
  
              gdk_gc_set_clip_rectangle(gc, &clip);
-             _gtk_draw_insertion_cursor (drawable, gc, &cursor_location, dir);
+             _gtk_draw_insertion_cursor (widget, drawable, gc, &cursor_location, dir);
               gdk_gc_set_clip_rectangle (gc, NULL);
 
               cursor_list = cursor_list->next;
index 1ed23146a4e4f8da319fc9e526905cb484ec7c3d..f1584560163c4051bf3fcbff9d9f92f63c1fa11e 100644 (file)
@@ -326,7 +326,7 @@ static void gtk_text_view_remove (GtkContainer *container,
                                   GtkWidget    *child);
 static void gtk_text_view_forall (GtkContainer *container,
                                   gboolean      include_internals,
-                                  GtkCallback   callback,
+                                 GtkCallback   callback,
                                   gpointer      callback_data);
 
 /* FIXME probably need the focus methods. */
@@ -633,18 +633,6 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
                                                         G_PARAM_READWRITE));
 
   
-  /*
-   * Style properties
-   */
-
-  gtk_widget_class_install_style_property (widget_class,
-                                          g_param_spec_boxed ("cursor_color",
-                                                              _("Cursor color"),
-                                                              _("Color with which to draw insertion cursor"),
-                                                              GDK_TYPE_COLOR,
-                                                              G_PARAM_READABLE));
-
-
   /*
    * Signals
    */
@@ -3270,7 +3258,7 @@ gtk_text_view_realize_cursor_gc (GtkTextView *text_view)
   if (text_view->cursor_gc)
     gdk_gc_unref (text_view->cursor_gc);
 
-  gtk_widget_style_get (GTK_WIDGET (text_view), "cursor_color", &cursor_color, NULL);
+  gtk_widget_style_get (GTK_WIDGET (text_view), "cursor-color", &cursor_color, NULL);
 
   if (!cursor_color)
     cursor_color = &red;
index 04fe3f31a19bf4df13396e74b24e21125930dc48..487c80f508d8b4c14a3dad5fa3a977b82446836c 100644 (file)
@@ -1074,7 +1074,18 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                                                             _("Width, in pixels, between focus indicator and the widget 'box'."),
                                                             0, G_MAXINT, 1,
                                                             G_PARAM_READWRITE));
-
+  gtk_widget_class_install_style_property (klass,
+                                          g_param_spec_boxed ("cursor-color",
+                                                              _("Cursor color"),
+                                                              _("Color with which to draw insertion cursor"),
+                                                              GDK_TYPE_COLOR,
+                                                              G_PARAM_READABLE));
+  gtk_widget_class_install_style_property (klass,
+                                           g_param_spec_float ("cursor-aspect-ratio",
+                                                               _("Cursor line aspect ratio"),
+                                                               _("Aspect ratio with which to draw insertion cursor"),
+                                                               0.0, 1.0, 0.033,
+                                                               G_PARAM_READABLE));
 }
 
 static void
index 4ef1acbaec5ee7bca0017e69975989728190c649..307c0689c6702b3c7c568937865efa5bef2e0264 100644 (file)
@@ -34,8 +34,7 @@ style "global-style-properties"
 #  xthickness = 20
   GtkButton::child_displacement_x = 1
   GtkButton::child_displacement_y = 1
-  GtkSpinButton::shadow_type = etched-out
-  GtkEntry::cursor_color = "#ff0000"
+  GtkWidget::cursor_color = "#ff0000"
   GtkToolbar::space_size = 10
   GtkToolbar::space_style = line
   GtkToolbar::button_relief = none